package org.railage.server.entities;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedNativeQuery;

import org.railage.common.dto.PassengerDTO;

/**
 * Passenger entity
 * 
 * @author Cyril Fertikov
 * 
 */
@NamedNativeQuery(
		name = "getPassengersByTrip", 
		query = "call proc_get_trip_passengers(:id_trip)", 
		resultClass = Passenger.class
)
@Entity
public class Passenger implements Serializable {
	private static final long serialVersionUID = 1986493282556922061L;

	@Id
	@Column(name = "id")
	private int id;

	@Column(name = "name")
	private String name;

	@Column(name = "surname")
	private String surname;

	@Column(name = "birthday")
	private Date birthday;

	@Column(name = "start_station")
	private String startStation;

	@Column(name = "finish_station")
	private String finishStation;

	public Passenger() {

	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSurname() {
		return surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public String getStartStation() {
		return startStation;
	}

	public void setStartStation(String startStation) {
		this.startStation = startStation;
	}

	public String getFinishStation() {
		return finishStation;
	}

	public void setFinishStation(String finishStation) {
		this.finishStation = finishStation;
	}

	public PassengerDTO toDTO() {
		PassengerDTO dto = new PassengerDTO();
		dto.setId(id);
		dto.setName(name);
		dto.setSurname(surname);
		dto.setBirthday(birthday);
		dto.setStartStation(startStation);
		dto.setFinishStation(finishStation);
		return dto;
	}

}
